package com.yuwei.module_sign

import androidx.activity.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.ToastUtils
import com.bw.lib_base.path.RouterPath
import com.bw.lib_common.view.BaseMvvmActivity
import com.yuwei.module_sign.databinding.ActivitySignListBinding
import com.yuwei.module_sign.viewmodel.SignViewModel
import com.yuwei.module_sign.adapter.AttendanceAdapter
import com.yuwei.module_sign.adapter.MinutesAdapter
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = RouterPath.MODULE_SIGN_DETAIL_ACTIVITY)
class SignListActivity : BaseMvvmActivity<ActivitySignListBinding>() {
    private val vm : SignViewModel by  viewModels<SignViewModel>()
    private val attendanceAdapter by lazy { AttendanceAdapter() }
    private val minutesAdapter by lazy { MinutesAdapter() }
    private val statusList = arrayListOf("全部","正常","迟到","早退","缺勤")
    override fun initViews() {
        super.initViews()
        vm.getSignList()
        minutesAdapter.data.addAll(statusList)
        minutesAdapter.setOnItemClickListener { adapter, view, position ->
            minutesAdapter.setIndex(position)
            minutesAdapter.notifyDataSetChanged()
        }
        vm.getSignList()
        binding.signListStatusRv.adapter = minutesAdapter
        binding.signListStatusRv.layoutManager = LinearLayoutManager(this,  LinearLayoutManager.HORIZONTAL, false)
        binding.signListRv.adapter = attendanceAdapter
        binding.signListRv.layoutManager = LinearLayoutManager(this)
        binding.signListBack.setOnClickListener {
            finish()
        }
    }
    override fun observeDataChange() {
        vm.getSignListSuccess.observe(this){
            attendanceAdapter.data.addAll(it)
            attendanceAdapter.notifyDataSetChanged()
        }
    }

    override fun getLayoutId(): Int = R.layout.activity_sign_list
}